package com.pattern.design.designpattern.Zeren;

/**
 * author:harisucici on 2018/10/10 08:34
 * email:harisucici@gmail.com
 * name:
 * todo:
 */
public abstract class Leader {
    /**
     * The Next handler.
     */
    public Leader nextHandler;

    /**
     * Limit int.
     *
     * @return the int
     */
    public abstract int limit();

    /**
     * Handle.
     *
     * @param money the money
     */
    public abstract void handle(int money);

    /**
     * Handle request.
     *
     * @param money the money
     */
    public void handleRequest(int money){
        if (money<=limit()){
            handle(money);
        }else{
            if(nextHandler!=null){
                nextHandler.handleRequest(money);
            }
        }
    }
}
